package com.xjoyt.pay.master.controllers;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.xjoyt.pay.controllers.AbstractController;
import com.xjoyt.pay.dto.ExecuteResult;
import com.xjoyt.pay.dto.PageParam;
import com.xjoyt.pay.dto.PageResult;
import com.xjoyt.pay.master.interfaces.MerchantContract;
import com.xjoyt.pay.master.params.MerchantPageParam;
import com.xjoyt.pay.master.po.Merchant;
import com.xjoyt.pay.master.po.MerchantRate;
import com.xjoyt.pay.master.services.MerchantService;

@RestController
@RequestMapping("merchant")
public class MerchantController extends AbstractController implements MerchantContract {

	@Autowired
	private MerchantService service;

	// @Override
	// public ExecuteResult<?> create(@RequestBody
	// com.xjoyt.pay.merchant.register.po.Merchant merchant) {
	// return service.create(merchant);
	// }

	@Override
	public Merchant get(@PathVariable("id") String id) {
		return service.get(id);
	}
	
	@Override
	public List<MerchantRate> getMerchantRate(@PathVariable("id") String id) {
		return service.getMerchantRate(id);
	}

	@Override
	public ExecuteResult<String> resetKey(@PathVariable("id") String id) {
		return service.resetKey(id);
	}

	@Override
	public Merchant getByNo(@PathVariable("no") String no) {
		return service.getByNo(no);
	}

	@Override
	public Merchant getByDistributorIdAndCustomerNo(@PathVariable("distributorId") String distributorId,
			@PathVariable("no") String no) {
		return service.getByCustomerNo(distributorId, no);
	}

	@Override
	public ExecuteResult<?> update(@RequestBody com.xjoyt.pay.merchant.register.po.Merchant customer) {
		return service.update(customer);
	}

	@Override
	public PageResult<Merchant> loadPage(@RequestBody PageParam<MerchantPageParam> param) {
		return service.loadPage(param);
	}

	@Override
	public ExecuteResult<?> create(com.xjoyt.pay.merchant.register.po.Merchant param) {
		// TODO Auto-generated method stub
		return null;
	}

	@RequestMapping("findAll")
	public List<Merchant> findAll() {
		return service.findAll();
	}

}
